package com.service.impl;

import com.common.pojo.LoginUser;
import com.entity.UserTable;
import com.mapper.UserMapper;
import com.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: GuoTong
 * @createTime: 2021-06-23 10:24
 * @since JDK 1.8 OR 11
 **/
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<UserTable> getUsers() {

        return userMapper.getUsers();
    }

    @Override
    public UserTable getUserById(int userId) {
        return userMapper.getUserById(userId);
    }

    @Override
    public List<UserTable> getUserByLimit(int startIndex, int everyPageSize) {
        return userMapper.getUserByLimit(startIndex, everyPageSize);
    }

    @Override
    public int insertInToUserTable(UserTable tableObj) {
        return userMapper.insertInToUserTable(tableObj);
    }

    @Override
    public int updateUserTableById(UserTable tableObj) {
        return userMapper.updateUserTableById(tableObj);
    }

    @Override
    public int deleteusertablebyid(int id) {
        return userMapper.deleteusertablebyid(id);
    }

    @Override
    public UserTable queryForEntity(LoginUser user) {
        String username = user.getUsername();
        String password = user.getPassword();
        return userMapper.selectByUserNameAndPassword(username, password);
    }

    @Override
    public UserTable getbyUserEmail(String userEmail) {

        return userMapper.selectByEmail(userEmail);
    }
}
